﻿package baidu.ui.controls.list
{
    import baidu.ui.controls.*;
    import flash.events.*;

    public class ListCell extends LabelButton implements IListCell
    {
        protected var _data:Object;
        protected var _listData:ListData;
        public static var defaultStyles:Object = {skin:"ListCell_Skin", iconSkin:null};

        public function ListCell()
        {
            toggle = true;
            return;
        }// end function

        override public function get classStyles() : Object
        {
            return mergeStyles(super.classStyles, defaultStyles);
        }// end function

        override protected function toggleSelected(event:MouseEvent) : void
        {
            return;
        }// end function

        public function get data()
        {
            return this._data;
        }// end function

        public function set data(param1) : void
        {
            this._data = param1;
            label = this._data.label;
            icon = this._data.icon;
            return;
        }// end function

        public function get listData() : ListData
        {
            return this._listData;
        }// end function

        public function set listData(param1:ListData) : void
        {
            this._listData = param1;
            return;
        }// end function

        override protected function drawLayout() : void
        {
            var _loc_3:Number = NaN;
            var _loc_1:* = Number(getStyleValue("padding"));
            var _loc_2:Number = 0;
            if (_icon != null)
            {
                _icon.x = _loc_1;
                _icon.y = Math.round((_height - _icon.height) / 2);
                _loc_2 = _icon.width + _loc_1;
            }
            if (label.length > 0)
            {
                textField.visible = true;
                _loc_3 = Math.max(0, _width - _loc_2 - _loc_1 * 2);
                textField.width = _loc_3;
                textField.height = textField.textHeight + 4;
                textField.x = _loc_2 + _loc_1;
                textField.y = Math.round((_height - textField.height) / 2);
            }
            else
            {
                textField.visible = false;
            }
            background.width = _width;
            background.height = _height;
            return;
        }// end function

    }
}
